package com.xuerhua.yxt.service.impl;

import java.util.Date;
import java.util.List;

import com.xuerhua.yxt.model.TeacherInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xuerhua.yxt.dao.TeacherRoutineParamMapper;
import com.xuerhua.yxt.model.TeacherRoutineParam;
import com.xuerhua.yxt.reqVo.BaseQueryVO;
import com.xuerhua.yxt.service.ITeacherRoutineParamService;

@Service("teacherRoutineParamService")
class TeacherRoutineParamServiceImpl implements ITeacherRoutineParamService {

	@Autowired
	private TeacherRoutineParamMapper teacherRoutineParamMapper;
	
	@Override
	public List<TeacherRoutineParam> selectList(BaseQueryVO vo) {
		return teacherRoutineParamMapper.selectList(vo);
	}

	@Override
	public List<TeacherRoutineParam> selectByTeacherId(TeacherInfo teacherInfo) {
		return teacherRoutineParamMapper.selectByTeacherId(teacherInfo);
	}
	
	@Override
	public boolean isJudgeTeacher(Integer teacherId, Integer schoolId) {
		int count = teacherRoutineParamMapper.selectCountByTeacherId(teacherId,schoolId);
		return count > 0 ? true : false;
	}

	@Override
	public TeacherRoutineParam selectById(Integer id) {
		return teacherRoutineParamMapper.selectByPrimaryKey(id);
	}

	@Override
	public int addUpdate(TeacherRoutineParam record) {
		if(record.getId() != null) {
			record.setUpdateTime(new Date());
			return teacherRoutineParamMapper.updateByPrimaryKeySelective(record);
		}
		return teacherRoutineParamMapper.insertSelective(record);
	}

}
